<div class="main layui-clear">
    <div class="wrap">
        <div class="content">
            <div class="fly-tab fly-tab-index">
                <span>
                    <a href="{:U('home/note/all')}">
                        全部
                    </a>
                    <a href="{:U('home/note/note')}">
                        未结帖
                    </a>
                    <a href="{:U('home/note/save')}">
                        已采纳
                    </a>
                    <a href="{:U('home/note/best')}">
                        精帖
                    </a>
                    <a href="{:U('home/person/user_center')}">
                        我的帖
                    </a>
                </span>
                <form action="{:U('search')}" class="fly-search" id="form1">
                    <i class="iconfont icon-sousuo" id="search_button">
                    </i>
                    <input class="layui-input" autocomplete="off" placeholder="搜索内容，回车跳转"
                    type="text" name="word">
                </form>
                <a href="{:U('home/jie/add')}" class="layui-btn jie-add">
                    发表新帖
                </a>
            </div>
            
            <ul class="fly-panel fly-list">

                <?php foreach ($question as  $value){ ?>

                    <li class="fly-list-li">
                        <a href="{:U('home/person/userinfo',array('id'=>$value['uid']))}" class="fly-list-avatar">
                            <img src="<?php if(empty($value['face'])){
                                echo C('DEFAULT_FACE');
                            }else{
                                echo $value['face'];
                                 } ?>">
                        </a>
                        <h2 class="fly-tip">
                            <a href="/PHP/projects/BBS_fly/index.php?m=home&c=jie&a=detail&id=<?php echo $value['qid']; ?>">
                                <?php echo $value['title']; ?>
                            </a>
                        </h2>
                        <p>
                            <span>
                                <a href="{:U('home/person/userinfo',array('id'=>$value['uid']))}">
                                    <?php echo $value['nickname']; ?>
                                </a>
                            </span>
                            <span>
                               <?php  $time=date('Y-m-d H:i:s',$value['create_time']); echo $time; ?>
                            </span>
                            <span>
                                技术闲谈
                            </span>
                            <span class="fly-list-hint">
                                <i class="iconfont" title="回答"></i>
                                <?php echo $value['answer_num']; ?>
                                <i class="iconfont" title="人气">
                                    
                                </i>
                                <?php echo $value['view_num'];  ?>
                            </span>
                        </p>
                    </li>

                <?php }  ?>
               
            </ul>

            <div style="text-align: center">
                <div class="laypage-main">
                    <?php 

                        for($i=1;$i<=$page_count;$i++){
                            if($_GET['page'] == $i){
                                echo '<span class="laypage-curr">'.$i.'</span>';
                            }
                            else{
                                echo '<a href="'.U('index',array('page'=>$i)).'">'.$i.'</a>';
                            }
                        }

                    ?>


                    <span>
                        …
                    </span>
                    <a href="/jie/page/293/" class="laypage-last" title="尾页">
                        尾页
                    </a>
                    <a href="/jie/page/2/" class="laypage-next">
                        下一页
                    </a>
                </div>
            </div>

           
        </div>
    </div>



    <div class="edge">
        <div class="fly-panel leifeng-rank">
            <h3 class="fly-panel-title">
                近一月回答榜 - TOP 12
            </h3>

            <dl>
                <?php foreach ($ans_num as $key => $value){ ?>

                    <dd>
                        <a href="{:U('home/person/userinfo',array('id'=>$value['id']))}">
                            <img src="<?php echo $value['face']; ?>">
                            <cite>
                                <?php echo $value['nickname']; ?>
                            </cite>
                            <i>
                                <?php echo $value['answer_num']; ?>
                            </i>
                        </a>
                    </dd>                
                        
                <?php } ?>
            </dl>
            
        </div>
        <dl class="fly-panel fly-list-one">
            <dt class="fly-panel-title">
                最近热帖
            </dt>
            <?php foreach ($hot as $key => $value){ ?>
                <dd>
                    <a href="{:U('home/jie/detail',array('id'=>$value['id']))}">
                        <?php echo $value['title']; ?>
                    </a>
                    <span>
                        <i class="iconfont">
                            
                        </i>
                        <?php echo $value['view_num']; ?>
                    </span>
                </dd>
                
            <?php } ?>
          
        </dl>


        <dl class="fly-panel fly-list-one">
            <dt class="fly-panel-title">
                近期热议
            </dt>
            <?php foreach ($talk as $key => $value){ ?>

                <dd>
                    <a href="{:U('home/jie/detail',array('id'=>$value['id']))}">
                        <?php echo $value['title']; ?>
                    </a>
                    <span>
                        <i class="iconfont">
                            
                        </i>
                        <?php echo $value['answer_num']; ?>
                    </span>
                </dd>
                
            <?php } ?>
           
           
        </dl>
        
    </div>
</div>



<script type="text/javascript">

    document.getElementById('search_button').onclick = function(){

        document.getElementById('form1').submit();

    };


    layui.use(['form','jquery'], function(){
        var form = layui.form(),
        layer = layui.layer,
        $ = layui.jquery;

        //测试  假如成功说明jq程序执行没有问题   发送异步请求
        // $('#L_email').blur(function(event) {
        //     alert(8888);
        // });

        //监听提交
        form.on('submit(reg)', function(data){
            //假如每一项都验证通过就走这里  弹出7777
            //alert(7777);exit;
            //console.log(data);    //查看数据存储位置   在field的对象里面
            //只有当前台验证通过提交数据，后台才发送异步判断信息是否合法
            $.ajax({
                url: '{:U('home/reg/checkdata')}',
                type: 'POST',
                dataType: 'json',
                data: data.field,      //所以这里的数据是data.field
            })
            .done(function(respons){
                if(respons.error==1){
                    layer.msg(respons.info, function(){
                    });
                }else{
                    layer.alert(respons.info, {icon: 6},function  () {
                    location.replace('{:U('home/login/index')}')
                    });
                }
            })
            .fail(function(){
                console.log("error");
            })
            return false;         
        });


    });

</script>
